package cn.itcast.exception;

import cn.itcast.pojo.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

//@RestControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler(CustomException.class)
    public Result handleCustomException(CustomException e) {
        return Result.error(e.getMessage());
    }
    @ExceptionHandler(SystemException.class)
    public Result handleSystemException(SystemException e) {
        return Result.error(e.getMessage());
    }
    @ExceptionHandler(Exception.class)
    public Result handleException(Exception e) {
        System.out.println("未知异常");
        e.printStackTrace();
        return Result.error("亲,服务器正忙!!!");
    }
}
